#ifndef WHITEBOARD_H
#define WHITEBOARD_H

#include <QtGui/QWidget>
#include <QColor>
#include <QImage>
#include <QPoint>

class Whiteboard : public QWidget
{
    Q_OBJECT

public:
    Whiteboard(QWidget* pParent = 0);
    //~Whiteboard(void);

    bool loadImage(const QString& fileName);
    bool saveImage(const QString& fileName, const char* fileFormat);

    void setPenColor(const QColor& newColor);
    QColor getPenColor(void) const;

    void setPenWidth(int newWidth);
    int getPenWidth(void) const;

    bool isModified(void) const;

private:
    void drawLineTo(const QPoint& endPoint);
    void resizeImage(QImage* pImage, const QSize& newSize);

    QImage _image;
    QPoint _lastPoint;
    QColor _penColor;
    int _penWidth;

    bool _modified;
    bool _drawing;

protected:
    void mousePressEvent(QMouseEvent* pEvent);
    void mouseReleaseEvent(QMouseEvent* pEvent);
    void mouseMoveEvent(QMouseEvent* pEvent);
    void paintEvent(QPaintEvent* pEvent);
    void resizeEvent(QResizeEvent* pEvent);


public slots:
    void clearImage(void);
//    void print(void);

	void contextMenu(const QPoint& pos);

private slots:
	void menuLoadImage(void);
	void menuSaveImage(void);

	void menuPenColor(void);
	void menuPenWidth(void);
};

#endif // WHITEBOARD_H
